<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Inserimento Personale</title>

<link rel="stylesheet" type="text/css" href="../style.css" />
<script type="text/javascript">
/** 
 * Funzione di controllo della correttezza dei dati inseriti
 */
function check( form ) {
	var cf = form.cf.value;
	var mail = form.mail.value;
	var pass = form.pass.value;
	var cpass = form.cpass.value;
	var usr = form.usr.value;
	// controllo del codice fiscale
	var cfRegExp = /^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/i;
	if( !cf.match( cfRegExp ) ) {
		alert("Codice fiscale non valido");
		return false;
	}
	// controllo della mail
	var mailRegExp = /^[a-z|0-9|\.|\-|_]+@\w+.[a-z]+$/i;
	if( !mail.match( mailRegExp ) ) {
		alert("Indirizzo e-mail non valido");
		return false;
	}
	// controllo dello username
	if( usr == null ) {
		alert("Inserire uno username");
		return false;
	}
	// controllo della password
	if( pass == null ) {
		alert("Password non valida");
		return false;
	}
	// controllo conferma password
	if( cpass == null || pass != cpass ) {
		alert("Le due password non coincidono");
		return false;
	}
	return true;
}
</script>

</head>


<body>
	
	<center><i><font size="5">Profilo Amministratore</font></i></center><hr>
	
	<p><i><font size="4">Inserimento personale</font></i></p>
	
	<form action="../InserimentoPersonale" method="post"
		onsubmit="return check(this)">
		<table cellspacing="5">
			<tr>
				<td align="right">Nome*:</td>
				<td><input type="text" name="nome" size="50"/></td>
			</tr>
			<tr>
				<td align="right">Cognome*:</td>
				<td><input type="text" name="cogn" size="50"/></td>
			</tr>
			<tr>
				<td align="right">Codice Fiscale*:</td>
				<td><input type="text" name="cf" size="50" maxlength="16"/></td>
			</tr>
			<tr>
				<td align="right">Indirizzo e-mail*:</td>
				<td><input type="text" name="mail" size="50"/></td>
			</tr>
			<tr>
				<td align="right">Username*:</td>
				<td><input type="text" name="usr" size="50"/></td>
			</tr>
			<tr>
				<td align="right">Password*:</td>
				<td><input type="password" name="pass" size="50"/></td>
			</tr>
			<tr>
				<td align="right">Conferma password*:</td>
				<td><input type="password" name="cpass" size="50"/></td>
			</tr>
			<tr>
				<td align="right">Tipologia:</td>
				<td>
					<input type="radio" value="amministratore" name="tipo"/>Amministratore 
					<input type="radio" value="addetto amministrativo" name="tipo"/>Addetto amministrativo 
					<input type="radio" value="dipendente" name="tipo" checked="checked"/>Dipendente
				</td>
			</tr>
			<tr>
				<td><input type="submit" value="Registra"></td>
			</tr>
		</table>
	</form>
	
	<p>
		<a href="gestionedipendenti.jsp"><button>Indietro</button></a>
	</p>
</body>
</html>